<!DOCTYPE html>
<html>
<head>
    <meta charset='utf-8'>
    <title>微信登录回调页面</title></title>
</head>
<script type="text/javascript" src="plugin/vue/dist/vue.js"></script>
<script type="text/javascript" src="plugin/axios/dist/axios.js"></script>
<script type="text/javascript" src="script/common.js"></script>
<body>
<div id="root">

</div>
<script type="text/javascript">
    new Vue({
       el:'#root',
       data:{

       },
       mounted(){
        let obj = parseUrlParams()
        this.$http.post("/login/wechatLogin",obj)
            .then(res => {
                res = res.data.resultObj
                let isWechat = res.isWechat
                if(isWechat != null && isWechat == true){
                    location.href = "/bind.html?accessToken="+res.accessToken+"&openid="+res.openid
                }else{
                    let token = res.token
                    let loginUser = res.loginUser
                    localStorage.setItem("token",token)
                    localStorage.setItem("loginUser",JSON.stringify(loginUser))
                    location.href="/index.html"
                }
            }).catch(res => {
                alert(res.data.message)
            })
       }
    })
</script>
</body>
</html>